package com.mes.cloud.web.productpricegroup;

import com.mes.cloud.api.dto.request.productpricegroup.*;
import com.mes.cloud.api.dto.response.productpricegroup.ProductPriceGroupProductProductDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.productpricegroup.ProductPriceGroupProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author wxm
 * @version 2019-09-24 14:49:07
 * @email xiaomin.wu1@pactera.com
 */
@Api(tags = "产品价格组-产品关联", value = "产品价格组-产品关联接口")
@RestController
@RequestMapping(value = "/productPriceGroupProduct")
public class ProductPriceGroupProductController  {

    private ProductPriceGroupProductService productPriceGroupProductService;

    @Autowired
    public ProductPriceGroupProductController(ProductPriceGroupProductService productPriceGroupProductService) {
        this.productPriceGroupProductService = productPriceGroupProductService;
    }

    /**
     * 功能: 产品价格组-产品关联分页查询
     *
     * @param productPriceGroupProductPageListRequest
     * @return JsonResult<CommPager<ProductPriceGroupProductDto>>
     */
    @ApiOperation(value = "产品价格组-产品关联分页查询", notes = "产品价格组-产品关联分页查询")
    @PostMapping(value = "/pageList")
    public JsonResult<CommPager<ProductPriceGroupProductProductDto>> pageList(@Valid @RequestBody ProductPriceGroupProductPageListRequest productPriceGroupProductPageListRequest) {
        return productPriceGroupProductService.pageList(productPriceGroupProductPageListRequest);
    }

    /**
     * 功能: 产品价格组-绑定产品
     *
     * @param productPriceGroupProductBindProductRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品价格组-绑定产品", notes = "产品价格组-绑定产品")
    @PostMapping(value = "/bindProduct")
    public JsonResult bindProduct(@Valid @RequestBody ProductPriceGroupProductBindProductRequest productPriceGroupProductBindProductRequest) {
        return productPriceGroupProductService.bindProduct(productPriceGroupProductBindProductRequest);
    }

    /**
     * 更新绑定产品中间表信息
     * @param productPriceGroupProductUpdateRequest
     * @return
     */
    @ApiOperation(value = "产品价格组-更新绑定产品中间表信息", notes = "产品价格组-更新绑定产品中间表信息")
    @PostMapping(value = "/update")
    public JsonResult update(@Valid @RequestBody ProductPriceGroupProductUpdateRequest productPriceGroupProductUpdateRequest) {
        return productPriceGroupProductService.update(productPriceGroupProductUpdateRequest);
    }

    /**
     * 功能: 产品价格组-解绑产品
     *
     * @param productPriceGroupProductBatchDeleteRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品价格组-解绑产品", notes = "产品价格组-解绑产品")
    @PostMapping(value = "/batchDelete")
    public JsonResult batchDelete(@Valid @RequestBody ProductPriceGroupProductBatchDeleteRequest productPriceGroupProductBatchDeleteRequest) {
        return productPriceGroupProductService.batchDelete(productPriceGroupProductBatchDeleteRequest);
    }

    /**
     * 功能: 产品定价查询
     *
     * @param pageRequest
     * @return JsonResult
     */
    @ApiOperation(value = "产品定价查询", notes = "产品定价查询")
    @PostMapping(value = "/findPriceGroupByProductId")
    public JsonResult<CommPager<ProductPriceGroupProductProductDto>> findPriceGroupByProductId(@Valid @RequestBody ProductPriceGroupProductPageRequest pageRequest) {
        return productPriceGroupProductService.findPriceGroupByProductId(pageRequest);
    }

}
